﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BFlatCompile.Nodes
{
	internal class MapDefinition : Expression
	{
		public Expression[] Keys { get; private set; }
		public Expression[] Values { get; private set; }
		public Token Token { get; private set; }
		public Token[] KeyTokens { get; private set; }

		public MapDefinition(IList<Expression> keys, IList<Expression> values, Token token, IList<Token> keyTokens)
		{
			this.Keys = keys.ToArray();
			this.Values = values.ToArray();
			this.Token = token;
			this.KeyTokens = keyTokens.ToArray();
		}

		public override void ResolveCode(Class c, Dictionary<object, object> parents)
		{
			foreach (Expression expr in this.Keys.Concat<Expression>(this.Values))
			{
				expr.ResolveCode(c, parents);
			}
		}

		public override void ResolveClassToThis(Class c)
		{
			foreach (Expression expr in this.Keys.Concat<Expression>(this.Values))
			{
				expr.ResolveClassToThis(c);
			}
		}
	}
}
